//                       .::::.
//                     .::::::::.
//                    :::::::::::
//                 ..:::::::::::'
//              '::::::::::::'
//                .::::::::::
//           '::::::::::::::..
//                ..::::::::::::.
//              ``::::::::::::::::
//               ::::``:::::::::'        .:::.
//              ::::'   ':::::'       .::::::::.
//            .::::'      ::::     .:::::::'::::.
//           .:::'       :::::  .:::::::::' ':::::.
//          .::'        :::::.:::::::::'      ':::::.
//         .::'         ::::::::::::::'         ``::::.
//     ...:::           ::::::::::::'              ``::.
//    ```` ':.          ':::::::::'                  ::::..
//                       '.:::::'                    ':'````..
package com.xw.controller.api;

import com.xw.service.PlayRecordService;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.Map;

@Controller
@RequestMapping("/api/playRecord/")
@Scope("prototype")
public class ApiPlayRecordController {

    @Resource
    private PlayRecordService playRecordService;


    /**
     * 删除观看历史（支持批量删除）
     * @param userId    用户id
     * @param ids       删除观看历史记录id 逗号分隔
     * @return
     */
    @RequestMapping(value = "delPlayRecordByUserId",method = RequestMethod.POST)
    @ResponseBody
    public Object delPlayRecordByUserId(String userId,String ids){
        Map map = playRecordService.delPlayRecordByUserId(userId,ids);
        return map;
    }

    /**
     * 查询用户查看子视频进度
     * @param userId
     * @param videoItemId 子视频id
     * @return
     */
    @RequestMapping(value = "findPlayRecordByVideoItemId",method = RequestMethod.POST)
    @ResponseBody
    public Object findPlayRecordByVideoItemId(String userId,String videoItemId){
        Map map = playRecordService.findPlayRecordByVideoItemId(userId,videoItemId);
        return map;
    }

    /**
     * 观看历史 (查询的是具体到课程的哪个子视频)
     * @param userId
     * @param page
     * @param limit
     * @return
     */
    @RequestMapping(value = "findPlayRecordByUserId",method = RequestMethod.POST)
    @ResponseBody
    public Object findPlayRecordByUserId(String userId,Integer page,Integer limit){
        Map map = playRecordService.findPlayRecordByUserId(userId,page,limit);
        return map;
    }
}
